<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
<script type="text/javascript">

YUI().use("node",function(Y) {
	function Bird(name) {
	    this.name = name;
	}

	Bird.prototype.flighted   = true;  // Default for all Birds
	Bird.prototype.isFlighted = function () { return this.flighted };
	Bird.prototype.getName    = function () { return this.name };

	function Chicken(name) {
	    // Chain the constructors
	    Chicken.superclass.constructor.call(this, name);
	}
	// Chickens are birds
	Y.extend(Chicken, Bird);

	// Define the Chicken prototype methods/members
	Chicken.prototype.flighted = false; // Override default for all Chickens


	function showInheritance() {
	    var chicken = new Chicken('亲'),
	        results = Y.one('#demo');
		Y.log(chicken);
	    results.setContent('Running: ' + (new Date()));

	    results.append(((chicken instanceof Object) ?
	        "<p>chicken IS an instance of Object.</p>" :
	        "<p>chicken IS NOT an instance of Object.</p>"));

	    results.append(((chicken instanceof Bird) ?
	        "<p>chicken IS an instance of Bird.</p>" :
	        "<p>chicken IS NOT an instance of Bird.</p>"));

	    results.append(((chicken instanceof Chicken) ?
	        "<p>chicken IS an instance of Chicken.</p>" :
	        "<p>chicken IS NOT an instance of Chicken.</p>"));

	    // Chicken instances inherit Bird methods and members
	    results.append(((chicken.isFlighted()) ?
	        "<p>chicken CAN fly.</p>" :
	        "<p>chicken CAN NOT fly.</p>"));

	    results.append("<p>chicken's name is " + chicken.getName() + ".</p>");
	}

	Y.on('click', showInheritance, '#demo_btn');

});

</script>
</head>
<body>
<div id="demo"></div>
<button id="demo_btn">开始</button>
</body>
</html>